import { IToolTip } from "../../../../../com/mui/manager/IToolTip";
import { NormalTooltip } from "./NormalTooltip";
import { ToolTipInfo } from "../../../model/ToolTipInfo";
import { EquipmentToolTipData } from "../../../resource/info/EquipmentToolTipData";
import { EquipmentUtil } from "../util/EquipmentUtil";
import { ItemData } from "../../../resource/info/ItemData";
import { Cache } from "../../../cache/Cache";
import { ToolTipCompareInfo } from "./skillRune/ToolTipCompareInfo";
import { MagicWeaponUtil } from "../../magicWeapon/MagicWeaponUtil";
//class Tooltip
    
    export  class Tooltip /* flash.display.Sprite */ implements IToolTip
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.tooTip1 = new NormalTooltip();
            this.tooTip2 = new NormalTooltip();
            return;
        }

        public set data(arg1)
        {
            var loc1=undefined;
            var loc2=undefined;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc7=null;
            var loc8=null;
            var loc9=null;
            var loc10=null;
            var loc11=0;
            var loc12=0;
            this.clear();
            if (arg1 is ToolTipInfo && arg1.type == NormalTooltip.ToolTipRenderType_Equipment) 
            {
                if ((loc5 = (loc3 = arg1 as ToolTipInfo).tooltipData as EquipmentToolTipData).isContrast) 
                {
                    if (loc6 = loc5.getSameDressingOn()) 
                    {
                        (loc7 = new EquipmentToolTipData(loc6, loc5.equipmentsOnPlayer)).isContrast = false;
                        loc7.isShowEquipped = true;
                        loc1 = loc8 = new ToolTipInfo(NormalTooltip.ToolTipRenderType_Equipment, loc7);
                        loc2 = arg1;
                    }
                    else 
                    {
                        loc5.isContrast = false;
                        loc1 = arg1;
                    }
                }
                else 
                {
                    loc1 = arg1;
                }
                if (!loc5.isEquiped()) 
                {
                    loc5.showOwnEquip = EquipmentUtil.isOwnEquip(loc5.itemData);
                }
            }
            else if (arg1 is ToolTipInfo && arg1.type == NormalTooltip.ToolTipRenderType_MagicWeapon && arg1.tooltipData is ItemData) 
            {
                loc4 = arg1.tooltipData as ItemData;
                if (!((loc9 = Cache.instance.pack.rolePackCache.getSameTypeMagicWeapon(loc4)) == null) && !(loc9.uid == loc4.uid) && loc4.isHasIdentify()) 
                {
                    (loc10 = new ToolTipCompareInfo(arg1.type, null)).tooltipData = loc9;
                    loc10.showUp = false;
                    loc10.showEquiped = true;
                    loc1 = loc10;
                    loc2 = arg1;
                    ToolTipCompareInfo(loc2).showUp = !MagicWeaponUtil.isNoPropertyWeapon(arg1.tooltipData as ItemData);
                    ToolTipCompareInfo(loc2).showEquiped = false;
                    loc11 = MagicWeaponUtil.getMainProperty(arg1.tooltipData as ItemData);
                    loc12 = MagicWeaponUtil.getMainProperty(loc9);
                    ToolTipCompareInfo(loc2).upValue = loc11 - loc12;
                }
                else 
                {
                    loc1 = arg1;
                }
            }
            else 
            {
                loc1 = arg1;
            }
            if (loc1) 
            {
                this.tooTip1.data = loc1;
                this.addChild(this.tooTip1);
            }
            if (loc2) 
            {
                this.tooTip2.data = loc2;
                this.addChild(this.tooTip2);
                this.tooTip1.x = this.tooTip2.x + this.tooTip2.width + 5;
                this.tooTip1.y = this.tooTip2.y;
            }
            else 
            {
                this.tooTip1.x = 0;
                this.tooTip1.y = 0;
            }
            return;
        }

        /* internal  */clear(): void
        {
            if (this.tooTip1.parent) 
            {
                this.tooTip1.parent.removeChild(this.tooTip1);
            }
            if (this.tooTip2.parent) 
            {
                this.tooTip2.parent.removeChild(this.tooTip2);
            }
            return;
        }

        /* internal  */updatePos(): void
        {
            return;
        }

        public dispose(): void
        {
            this.tooTip1.dispose();
            this.tooTip2.dispose();
            return;
        }

        public /* override */ get width(): number
        {
            var loc1=0;
            if (this.tooTip1 && this.tooTip1.parent) 
            {
                loc1 = loc1 + this.tooTip1.width;
            }
            if (this.tooTip2 && this.tooTip2.parent) 
            {
                loc1 = loc1 + this.tooTip2.width;
            }
            if (loc1 == 0) 
            {
                loc1 = super.width;
            }
            return loc1;
        }

        public /* override */ get height(): number
        {
            if (this.tooTip1.parent && !this.tooTip2.parent) 
            {
                return this.tooTip1.height;
            }
            if (!this.tooTip1.parent && this.tooTip2.parent) 
            {
                return this.tooTip2.height;
            }
            if (this.tooTip1.parent && this.tooTip2.parent) 
            {
                return Math.max(this.tooTip1.height, this.tooTip2.height);
            }
            return 0;
        }

        public static /* const */ToolTipRenderType_Text: string=NormalTooltip.ToolTipRenderType_Text;

        public static /* const */ToolTipRenderType_Equipment: string=NormalTooltip.ToolTipRenderType_Equipment;

        public static /* const */ToolTipRenderType_Item: string=NormalTooltip.ToolTipRenderType_Item;

        public static /* const */ToolTipRenderType_Skill: string=NormalTooltip.ToolTipRenderType_Skill;

        public static /* const */ToolTipRenderType_ShortcutItem: string=NormalTooltip.ToolTipRenderType_ShortcutItem;

        public static /* const */ToolTipRenderType_Mounts: string=NormalTooltip.ToolTipRenderType_Mounts;

        public static /* const */ToolTipRenderType_WXSkill: string=NormalTooltip.ToolTipRenderType_WXSkill;

        public static /* const */ToolTipRenderType_GuildSkill: string=NormalTooltip.ToolTipRenderType_GuildSkill;

        public static /* const */ToolTipRenderType_HolyRune: string=NormalTooltip.ToolTipRenderType_HolyRune;

        public static /* const */ToolTipRenderType_MagicWeapon: string=NormalTooltip.ToolTipRenderType_MagicWeapon;

        public static /* const */ToolTipRenderType_MountStartsTarget: string=NormalTooltip.ToolTipRenderType_MountStartsTarget;

        public static /* const */ToolTipRenderType_MountEquip: string=NormalTooltip.ToolTipRenderType_MountEquip;

        public /* var */tooTip1: NormalTooltip;

        public /* var */tooTip2: NormalTooltip;
    }
